﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebApiDemo.Models;
using WebApiDemo.CustomResponses;
namespace WebApiDemo.Controllers
{
    public class ValuesController : ApiController
    {

        private BetterNotFoundResult BetterNotFound(string message)
        {
            return new BetterNotFoundResult(message, this);
        }
        // GET api/values
        public IHttpActionResult Get()
        {
            return Ok(new string[] { "value1", "value2" });

        }

        // GET api/values/5
        public IHttpActionResult Get(int id)
        {
            if (id>10)
            {
                return Ok(new Basic() { Id = 10, Name = "Basic Name" });

            }
            else
            {
                return BetterNotFound("Pick a higher number");
                
            }
        }

        // POST api/values
        public IHttpActionResult Post([FromBody]Basic value)
        {

            return Ok<Basic>(new Basic());
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}
